package com.boot.unity.api.common;

import lombok.Data;

@Data
public class Result<T> {
    private String code;
    private String msg;
    private T data;

    public Result() {
    }

    public Result(String code, String msg) {
        this.code = code;
        this.msg = msg;
        this.data = null;
    }

    public Result(String code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public Result(ResultCodeEnum resultCodeEnum) {
        this.code = resultCodeEnum.code;
        this.msg = resultCodeEnum.msg;
        this.data = null;
    }

    public Result(ResultCodeEnum resultCodeEnum,T data) {
        this.code = resultCodeEnum.code;
        this.msg = resultCodeEnum.msg;
        this.data = data;
    }

    public static Result success(){
        return new Result(ResultCodeEnum.SUCCESS);
    }

    public static Result fail(){
        return new Result(ResultCodeEnum.FAIL);
    }
}
